Skip to content

Conversation

lastmjs
Copy link
Member

@lastmjs lastmjs commented Jul 30, 2025

Overview

The JavaScript target would be more useful (especially to Azle developers) if it exported the IDL type objects that it generates. We also no longer need the factory functions as of 3.0.0, thus we will mark them deprecated and provide direct exports for that previous functionality.

Requirements

The JavaScript target should export all of the IDL type objects, including the generated IDL.Service and init args, without the need to use a factory function.

Considerations

There are no breaking changes besides some formatting of the generated JavaScript files. The idflFactory and init functions have been marked as deprecated but not removed. Developers can choose to import the IDL type objects now, but they are not forced to. This is mainly an ergonomic change with deprecations to prepare for a future with the best developer experience by default.

@lastmjs lastmjs linked an issue Jul 30, 2025 that may be closed by this pull request
@lastmjs lastmjs changed the title Javascript exports improvements to the JavaScript target Jul 30, 2025
Copy link

github-actions bot commented Jul 30, 2025

Name Max Mem (Kb) Encode Decode
blob 4_224 4_207_112 ($\textcolor{red}{0.01\%}$) 2_119_022 ($\textcolor{green}{-0.11\%}$)
btreemap 75_456 4_290_588_958 ($\textcolor{green}{-0.00\%}$) 15_185_828_516 ($\textcolor{green}{-0.49\%}$)
nns 192 ($\textcolor{red}{50.00\%}$) 1_580_661 ($\textcolor{green}{-19.90\%}$) 3_226_561 ($\textcolor{green}{-41.33\%}$)
nns_list_proposal 1_088 6_541_851 ($\textcolor{green}{-4.21\%}$) 46_648_099 ($\textcolor{green}{-30.55\%}$)
option_list 128 7_529_286 ($\textcolor{green}{-0.01\%}$) 24_840_141 ($\textcolor{green}{-3.43\%}$)
text 6_336 4_203_601 ($\textcolor{green}{-0.00\%}$) 7_877_306 ($\textcolor{green}{-0.00\%}$)
variant_list 128 7_524_789 ($\textcolor{green}{-0.80\%}$) 23_264_809 ($\textcolor{green}{-3.98\%}$)
vec_int16 16_704 123_692_906 ($\textcolor{green}{-0.00\%}$) 952_128_418 ($\textcolor{green}{-6.58\%}$)
  • Parser cost: 14_609_447 ($\textcolor{green}{-4.39\%}$)
  • Extra args: 2_475_134 ($\textcolor{green}{-23.98\%}$)
Click to see raw report
---------------------------------------------------

Benchmark: blob
  total:
    instructions: 6.33 M (-0.03%) (change within noise threshold)
    heap_increase: 66 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 4.21 M (0.01%) (change within noise threshold)
    heap_increase: 66 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 2.12 M (-0.11%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: text
  total:
    instructions: 12.08 M (-0.00%) (change within noise threshold)
    heap_increase: 99 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 4.20 M (-0.00%) (change within noise threshold)
    heap_increase: 66 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 7.88 M (-0.00%) (change within noise threshold)
    heap_increase: 33 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: vec_int16
  total:
    instructions: 1.08 B (improved by 5.87%)
    heap_increase: 261 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 123.69 M (-0.00%) (change within noise threshold)
    heap_increase: 261 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 952.13 M (improved by 6.58%)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: btreemap
  total:
    instructions: 19.48 B (-0.39%) (change within noise threshold)
    heap_increase: 1179 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 4.29 B (-0.00%) (change within noise threshold)
    heap_increase: 159 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 15.19 B (-0.49%) (change within noise threshold)
    heap_increase: 1020 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: option_list
  total:
    instructions: 32.37 M (improved by 2.65%)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 7.53 M (-0.01%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 24.84 M (improved by 3.43%)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: variant_list
  total:
    instructions: 30.79 M (improved by 3.22%)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 7.52 M (-0.80%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 23.26 M (improved by 3.98%)
    heap_increase: 2 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: nns
  total:
    instructions: 20.25 M (improved by 14.17%)
    heap_increase: 3 pages (regressed by 50.00%)
    stable_memory_increase: 0 pages (no change)

  0. Parsing (scope):
    calls: 1 (no change)
    instructions: 14.61 M (improved by 4.39%)
    heap_increase: 3 pages (regressed by 50.00%)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 1.58 M (improved by 19.90%)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 3.23 M (improved by 41.33%)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: nns_list_proposal
  total:
    instructions: 53.19 M (improved by 28.12%)
    heap_increase: 17 pages (no change)
    stable_memory_increase: 0 pages (no change)

  1. Encoding (scope):
    calls: 1 (no change)
    instructions: 6.54 M (improved by 4.21%)
    heap_increase: 3 pages (no change)
    stable_memory_increase: 0 pages (no change)

  2. Decoding (scope):
    calls: 1 (no change)
    instructions: 46.65 M (improved by 30.55%)
    heap_increase: 14 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: extra_args
  total:
    instructions: 2.48 M (improved by 23.98%)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Summary:
  instructions:
    status:   Improvements detected 🟢
    counts:   [total 9 | regressed 0 | improved 6 | new 0 | unchanged 3]
    change:   [max -55 | p75 -780.68K | median -1.02M | p25 -20.81M | min -75.51M]
    change %: [max -0.00% | p75 -0.39% | median -3.22% | p25 -14.17% | min -28.12%]

  heap_increase:
    status:   Regressions detected 🔴
    counts:   [total 9 | regressed 1 | improved 0 | new 0 | unchanged 8]
    change:   [max +1 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max +50.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

  stable_memory_increase:
    status:   No significant changes 👍
    counts:   [total 9 | regressed 0 | improved 0 | new 0 | unchanged 9]
    change:   [max 0 | p75 0 | median 0 | p25 0 | min 0]
    change %: [max 0.00% | p75 0.00% | median 0.00% | p25 0.00% | min 0.00%]

---------------------------------------------------

Only significant changes:
| status | name                           | calls |     ins |  ins Δ% |  HI |   HI Δ% | SMI |  SMI Δ% |
|--------|--------------------------------|-------|---------|---------|-----|---------|-----|---------|
|   -    | option_list                    |       |  32.37M |  -2.65% |   2 |   0.00% |   0 |   0.00% |
|   -    | variant_list                   |       |  30.79M |  -3.22% |   2 |   0.00% |   0 |   0.00% |
|   -    | option_list::2. Decoding       |     1 |  24.84M |  -3.43% |   2 |   0.00% |   0 |   0.00% |
|   -    | variant_list::2. Decoding      |     1 |  23.26M |  -3.98% |   2 |   0.00% |   0 |   0.00% |
|   -    | nns_list_proposal::1. Encoding |     1 |   6.54M |  -4.21% |   3 |   0.00% |   0 |   0.00% |
|  +/-   | nns::0. Parsing                |     1 |  14.61M |  -4.39% |   3 | +50.00% |   0 |   0.00% |
|   -    | vec_int16                      |       |   1.08B |  -5.87% | 261 |   0.00% |   0 |   0.00% |
|   -    | vec_int16::2. Decoding         |     1 | 952.13M |  -6.58% |   0 |   0.00% |   0 |   0.00% |
|  +/-   | nns                            |       |  20.25M | -14.17% |   3 | +50.00% |   0 |   0.00% |
|   -    | nns::1. Encoding               |     1 |   1.58M | -19.90% |   0 |   0.00% |   0 |   0.00% |
|   -    | extra_args                     |       |   2.48M | -23.98% |   0 |   0.00% |   0 |   0.00% |
|   -    | nns_list_proposal              |       |  53.19M | -28.12% |  17 |   0.00% |   0 |   0.00% |
|   -    | nns_list_proposal::2. Decoding |     1 |  46.65M | -30.55% |  14 |   0.00% |   0 |   0.00% |
|   -    | nns::2. Decoding               |     1 |   3.23M | -41.33% |   0 |   0.00% |   0 |   0.00% |

ins = instructions, HI = heap_increase, SMI = stable_memory_increase, Δ% = percent change

---------------------------------------------------
Successfully persisted results to canbench_results.yml

@lastmjs lastmjs force-pushed the javascript_exports branch from 6c5dfb7 to 9c53055 Compare July 30, 2025 20:41
@lastmjs lastmjs force-pushed the javascript_exports branch 4 times, most recently from f25c3b7 to e52a537 Compare August 7, 2025 21:15
ilbertt and others added 5 commits August 8, 2025 12:26
Looks like a recent bump of the Rust version on CI introduced new Clippy
lints that make CI fail on dfinity#668

This PR fixes those lint errors on the `next` branch.
Gets rid of the dodgy `is_empty` function that performed full traversals
of documents to tell if they were empty.
@lastmjs lastmjs force-pushed the javascript_exports branch from fc0f2a8 to 3ef2028 Compare August 11, 2025 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JS target improvements
5 participants